package cn.bearspark.schedule.provider;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * 定时服务的启动类
 *
 * @author f
 */
@EnableDubbo
@EnableDiscoveryClient
@SpringBootApplication
public class ScheduleApplication {

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(ScheduleApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE);
        springApplication.run(args);

        // 启动一个和主线程生命周期绑定的线程，防止主线程自动退出
        new Thread(() -> {
            synchronized (ScheduleApplication.class) {
                try {
                    ScheduleApplication.class.wait();
                } catch (Exception ignored) {
                }
            }
        }).start();
    }

}
